package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.certifition.ResidentCertificationBean;
import com.xinfu.newproject.bean.certifition.ResidentCertificationBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.certifition.QueryPropertyModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class QueryPropertyPresenter {
    private IView.IQueryPropertyView mIQueryPropertyView;

    private QueryPropertyModel mQueryPropertyModel;

    public QueryPropertyPresenter(IView.IQueryPropertyView iQueryPropertyView) {
        this.mIQueryPropertyView = iQueryPropertyView;
        mQueryPropertyModel = new QueryPropertyModel();
    }

    /**
     *
     */
    public void queryProperty() {

        ResidentCertificationBody residentCertificationBody = new ResidentCertificationBody(mIQueryPropertyView.header(), mIQueryPropertyView.userId(), mIQueryPropertyView.auditRes());

        mQueryPropertyModel.queryProperty(residentCertificationBody, new MyCallBack<ResidentCertificationBean>() {
            @Override
            public void onSuccess(ResidentCertificationBean residentCertificationBean) {

                if (residentCertificationBean.isSuccess()) {
                    mIQueryPropertyView.getData(residentCertificationBean);
                } else {
                    mIQueryPropertyView.showToast(residentCertificationBean.getMessage());
                }
                mIQueryPropertyView.showToast(residentCertificationBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {

                mIQueryPropertyView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIQueryPropertyView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
